<template>
  <div class="article-list">
    <article-item v-for="i in channelData" :articleData="i" :key="i.art_id" />
  </div>
</template>
<script>
import ArticleItem from './article-item.vue'
import { getArticleList } from '@/api/home.js'
export default {
  name: 'ArticleList',
  components: {
    ArticleItem
  },
  props: {
    id: {
      type: Number
    }
  },
  data () {
    return {
      channelData: []
    }
  },
  created () {
    this.getData()
  },
  methods: {
    async getData () {
      const res = await getArticleList({
        channel_id: this.id,
        timestamp: Date.now()
      })
      this.channelData = res.data.results
      // console.log(res)
    }
  }
}
</script>
<style scoped lang="less">
.article-list {
  height: 100%;
  overflow-y: auto;
  padding: 0 16px;
}
</style>
